package com.ruoyi.modularbusiness.controller;

import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.modularbusiness.domain.VO.LogicVo;
import com.ruoyi.modularbusiness.service.LogicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.ruoyi.common.core.web.domain.AjaxResult.success;

/**
 * 表单验证逻辑
 *
 * @author liuzhen
 * @date 2023-04-12
 */
@RestController
@RequestMapping("/LogicController")
public class LogicController {

    @Autowired
    private LogicService logicService;

    @PostMapping("/gonghao")
    public AjaxResult gonghao(@RequestBody String numbers){
        String uid= SecurityUtils.getUserId().toString();
        List<LogicVo> list=logicService.gonghao(uid,numbers);
        if(list.size()<1){
            throw new ServiceException("不存在！");
        }else{
            return success(list.get(0).getNick_name());
        }
    }


}
